package com.spddr.pmos.jpa;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.spddr.pmos.domain.GeoLocation;

@Entity
@Table(name = "plant_info")
public class Plant extends PowerSystemResource implements GeoLocation {
	private static final long serialVersionUID = 1L;

	private PlantType type;
	private PowerGroup group;
	private Company company;
	private Reservoir reservoir;
	private Double lng;
	private Double lat;
	private String location;

	public Plant() {
		super();
	}

	public Plant(Long id) {
		super(id);
	}

	public Plant(Long id, String name) {
		super(id, name);
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "type", nullable = false)
	@JsonSerialize(using = cn.seqdata.jackson.TypeSerializer.IdName.class)
	public PlantType getType() {
		return this.type;
	}

	public void setType(PlantType type) {
		this.type = type;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "power_group")
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public PowerGroup getGroup() {
		return this.group;
	}

	public void setGroup(PowerGroup group) {
		this.group = group;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "company", nullable = false)
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public Company getCompany() {
		return this.company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "reservoir", nullable = false)
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public Reservoir getReservoir() {
		return this.reservoir;
	}

	public void setReservoir(Reservoir reservoir) {
		this.reservoir = reservoir;
	}

	@Column(name = "lng")
	@Override
	public Double getLng() {
		return this.lng;
	}

	public void setLng(Double lng) {
		this.lng = lng;
	}

	@Column(name = "lat")
	@Override
	public Double getLat() {
		return this.lat;
	}

	public void setLat(Double lat) {
		this.lat = lat;
	}

	@Column(name = "location")
	@Override
	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}
}